
window.onload = function (){
    //得到从前一个页面中传递的参数
    let id = getQuery("id");
    init(id);
}

/**
 * 初始化信息
 */
function init(id){
    axios.get("/goods/findById",{params:{id}}).then(resp =>{
        var info = resp.data;
        $("idSpan").innerHTML = info.id;
        $("nameSpan").innerHTML = info.name;
        $("createDateSpan").innerHTML = info.createDate;
        $("priceTxt").value = info.price;
    })
}

/**
 * 修改
 */
function update(){
    axios.get("/goods/update",{
        params: {
            id:$("idSpan").innerHTML,
            price:$("priceTxt").value
        }
    }).then(resp =>{
        if(resp.data == "ok"){
            location.href = "/goods/index.html";
        }
    })
}